package com.yinhai.common.security;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.yinhai.common.controller.BaseController;
@SuppressWarnings({ "unchecked", "rawtypes" })
@Controller
@RequestMapping(value = "/auth")
public class LoginController extends BaseController {
	
	@RequestMapping(value="/login", method = {RequestMethod.GET})
	public ModelAndView hello() throws Exception {
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("/login"); 
		return modelAndView;
	}
	
	@ResponseBody
	@RequestMapping(value="/loginError", method = {RequestMethod.GET})
	public Map loginError() throws Exception {
		Map result = new HashMap();
		result.put("error", true);
		result.put("error_msg", "用户名或密码错误！");
		return result;
	}
	
	@RequestMapping(value="/logout", method = {RequestMethod.GET})
	public ModelAndView logout() throws Exception {
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("/login"); 
		return modelAndView;
	}
	
	@RequestMapping(value="/index", method = {RequestMethod.GET})
	public ModelAndView index() throws Exception {
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("/index"); 
		return modelAndView;
	}
}
